<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>盒子居中--文本</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            width: 400px;
            height: 400px;
            background-color: pink;
            text-align: center;
        }

        .p1 {
            display: inline-block;
            width: 200px;
            height: 200px;
            background-color: skyblue;
            line-height: 200px;


        }
    </style>
</head>

<body>
    <div class="box">
        <span class="p1">水平居中</span>
    </div>
</body>

</html>